BaltechScript Protocol
Baltech Script is a small language to define simple actions the reader should execute. A Baltech Script consists of one or more commands processed sequentially when the script is run. Usually these actions are assigned to events such as ''card presentation'' or ''I/O port set to low'' in Autoread Mode based readers. Alternatively, the host can execute such a script via protocol using the AR.RunScript command.
A script has to be stored as a configuration value within the Scripts / Events Key, if it shall be assigned to an event. This configuration Key contains a list of all available configuration Values and the events assigned to them.
Script commands are never waiting or delaying execution. If they start a long running process (i.e. Toggle ), this process will be started asynchronously. This means that the script is not waiting until the corresponding command has finished.
Example
The following example describes a scenario in which the Baltech reader runs in Autoread Mode.
- As long as the reader is waiting for cards, the green LED should be enabled.
- On card presentation, the reader should read the card number and send it to the host.
- One of the input pins (Input0) shall be used as ''lock signal''. If this pin is set to ''low'', the reader will not send the card number to the host but beep three times (at 1 Hz frequency) and disable the green led while beeping.
- As soon as this pin is high again, the ID-engine will continue sending the card number to the host without beeping when detecting a valid card.
The script to be executed in case a presented card is deemed valid by the Baltech reader is stored in the Scripts / Events / OnAccepted configuration Value.
The desired script needs to decide if the pin labeled Input0 is low (logical false) or not:
- If Input0 is high (logical true), the script should be stopped and the default action should be executed. The default action for the OnAccepted event is to send the card number to the host.
- If Input0 is low, the script should toggle the beeper 3 times where the beeper shall be enabled for 500 ms on every beep. Furthermore the red led should be enabled for 3000 ms.
This script takes the following form:
- IfIoPort Input0 (hex code 44 04)
- DefaultAction (hex code 04)
- IfIoPort Input0 Not (hex code 44 04 80)
- Toggle Beeper 3 5 (hex code 03 02 03 05)
- ToggleInverted GreenLed 1 30 (hex code 06 00 01 1E)
A second script is needed to ensure that the green LED is enabled after the reader powers up. As soon as the reader is initialized completely, the host protocol is activated. Thus the Scripts / Events / OnEnabledProtocol event can be used to trigger the second script:
- Enable GreenLed (hex code 01 00)
Condition Stack
A condition stack, necessary for conditional execution of parts of a script, is included as a feature of the Baltech Script language. It consists of a list of flags which may be either false (=0) or true (=1). If the topmost flag is true, all subsequent commands will be executed. If the topmost flag is false, none of the subsequent commands is executed, except commands modifying the stack. When a script is started, the condition stack is always empty. Thus, all commands are executed. The following list summarizes all commands modifying the condition stack:
- All commands starting with If push a new flag onto the top of the stack ( IfIoPort, IfVar, IfProtocolEnabled, IfDip, IfState, IfTrue ).
- Some commands modify the top of the stack ( Not, Or, And )
- The AssignVar command removes the topmost flag from the stack.
The architecture allows an inverse polish notation for complex boolean expressions such as:
If "global state variable 8" is true and "dip switch 3" is off do X
Global State Variables
To save a script's state, 16 so-called global state variables are available. These variables are flags which can be set or cleared within a script. They keep their state even after the execution of a script. Thus, the next script can access the flags set by the previous script.
Initially, all 16 global state variables are cleared (=0).
It is possible to modify these global variables via a script or to copy a variable onto the top of the Condition Stack and vice-versa. Please refer to the description of the SetVar, ClearVar, AssignVar and IfVar functions for detailed information.